package com.hiof.moraa.server.controller.restfulservice;

import com.hiof.moraa.server.service.UserService;
import com.hiof.moraa.server.service.model.LoginStatus;
import com.hiof.moraa.server.service.model.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by IntelliJ IDEA.
 * User: manish
 * Date: 3/26/12
 * Time: 12:20 AM
 * To change this template use File | Settings | File Templates.
 */

@Controller
@RequestMapping("/restfulservice")
public class UserServiceController {
    @Autowired
    UserService userService;

    @RequestMapping(value = "/login", method = RequestMethod.POST)
    @ResponseBody
    public LoginStatus logIn(
            @RequestParam("username") String userName,
            @RequestParam("password") String password
    ) throws Exception {
        return userService.login(userName, password);
    }

    @RequestMapping(value = "/getUserInfo", method = RequestMethod.POST)
    @ResponseBody
    public UserInfo getUserInfo(
            @RequestParam("username") String userName,
            @RequestParam("routeId") int routeId
    ) throws Exception {
        return userService.getUserInfoByUsernameAndRouteId(userName, routeId);
    }
}